package per.jdz.tolerant;

import per.jdz.common.constants.FaultTolerant;
import per.jdz.spi.ExtensionLoader;

import java.io.IOException;

/**
 * @description:
 * @Author: Jdz
 * @CreateTime: 2024-03-16 23:22
 */
public class FaultTolerantFactory {


    public static FaultTolerantStrategy get(FaultTolerant faultTolerant){
        final String name = faultTolerant.name;
        return ExtensionLoader.getInstance().get(name);
    }

    public static FaultTolerantStrategy get(String name){
        return ExtensionLoader.getInstance().get(name);
    }

    public static void init() throws IOException, ClassNotFoundException {
        final ExtensionLoader extensionLoader = ExtensionLoader.getInstance();
        extensionLoader.loadExtension(FaultTolerantStrategy.class);
    }
}
